package com.weirong.smartvault.backservice.util.chart;

import com.weirong.smartvault.common.tools.spring.context.SpringContextUtil;
import com.weirong.smartvault.dao.ForeignCurrencyTypeRepository;

import java.lang.reflect.InvocationTargetException;
import java.text.ParseException;

/**
 * 于2017/12/26由 KFEB4 创建 .
 */
public class ChartCompareStockUse {
    private static ForeignCurrencyTypeRepository foreignCurrencyTypeRepository = SpringContextUtil.getBean(ForeignCurrencyTypeRepository.class);

    public static ChartOption buildOption(String date) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, ParseException {
        ChartOption option = new ChartOption();
        ChartOption stockOption = ChartStock.buildOption(date);
        ChartOption useOption = ChartUse.buildOption(date);

        option.title.text = date+"年 月度库存使用对比表";
        option.xAxis = stockOption.xAxis;

        setSeries(option,stockOption,"库存");
        setSeries(option,useOption,"使用");
        return option;
    }
    private static void setSeries(ChartOption option,ChartOption from,String addition){
        for (ChartOption.Series fs:from.series){
            String legendName = fs.name+addition;
            option.legend.data.add(legendName);
            ChartOption.Series series = new ChartOption.Series();
            option.series.add(series);
            series.name = legendName;
            series.type = "line";
            series.stack = "总量";
            series.data = fs.data;
        }
    }

}
